﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using FSS.UI;
public class WndLoading : UIWnd
{
    private void Start()
    {
        
    }

    private void Update()
    {
        
    }

    public override void OnWndCreate()
    {
        Debug.Log("WndLoading Created");
    }

    public override void OnWndShow()
    {
        Debug.Log("WndLoading OnWndShow");
    }

    public override void OnWndHide()
    {
        Debug.Log("WndLoading OnWndHide");
    }

    public override void OnWndDestroy()
    {
        Debug.Log("WndLoading OnWndDestroy");
    }

    public override void OnSetUIAttr(string name, GameObject go)
    {
        switch (name)
        {
            case "btnEnter":
                Button btnEnter = go.GetComponent<Button>();
                btnEnter.onClick.AddListener(() =>
                {
                    this.OnBtnClick(btnEnter.name, btnEnter.gameObject);
                });
                
                EventTriggerListenerEx.GetListener(btnEnter.transform, 1024, true).
                    onPointerClick += OnBtnClickEx;
                break;
            case "btnExit":
                Button btnExit = go.GetComponent<Button>();
                btnExit.onClick.AddListener(() =>
                {
                    this.OnBtnClick(btnExit.name, btnExit.gameObject);
                });
                EventTriggerListenerEx.GetListener(btnExit.transform, 4096, true).
                    onPointerClick += OnBtnClickEx;
                break;
        }
    }

    public override void OnBtnClick(string name, GameObject go)
    {
        switch(name)
        {
            case "btnEnter":
                Debug.Log("btnEnter");
                break;
            case "btnExit":
                UIManager.Instance.HideWnd("loading wnd", false);
                Debug.Log("btnExit");
                break;
        }
    }

    public void OnBtnClickEx(string name, int userData, PointerEventData ped)
    {
        Debug.Log("OnBtnClickEx name:" + name + " userData:" + userData);
    }
}
